feat: add Tailwind CSS v4 shadow support and inset shadows#277
Open
YevheniiKotyrlo wants to merge 1 commit intonativewind:mainfrom
Open
feat: add Tailwind CSS v4 shadow support and inset shadows#277YevheniiKotyrlo wants to merge 1 commit intonativewind:mainfrom
YevheniiKotyrlo wants to merge 1 commit intonativewind:mainfrom
Conversation
This PR adds two features for better Tailwind CSS v4 compatibility: 1. **Tailwind CSS v4 shadow variable defaults** - Tailwind v4 uses @Property to define initial-value for shadow CSS variables, but react-native-css doesn't support @Property - Added default values for tw-shadow, tw-inset-shadow, tw-ring-shadow, etc. to prevent "undefined variable" errors 2. **Inset shadow parsing support** - Added pattern matching for "inset" keyword in box-shadow values - Converts inset: "inset" to inset: true for React Native's boxShadow - Supports patterns: inset <x> <y> <blur> <spread> [color]
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds two features for better Tailwind CSS v4 compatibility in React Native:
Problem
Tailwind CSS v4 Shadow Variables
Tailwind CSS v4 uses
@propertyto define initial-value for shadow CSS variables:Since react-native-css doesn't support
@propertydeclarations, these variables are undefined when shadow utilities are used, causing runtime errors.Inset Shadows Not Supported
CSS
insetshadows likebox-shadow: inset 0 0 24px 0 #fffwere not being parsed because there was no pattern matching for theinsetkeyword.Solution
1. Root Variable Defaults
Added default values for Tailwind v4 shadow variables in
src/native-internal/root.ts:--tw-shadow--tw-shadow-color--tw-inset-shadow--tw-inset-shadow-color--tw-ring-shadow--tw-inset-ring-shadow--tw-ring-offset-shadowThese are set to transparent shadow values that get filtered out by
omitTransparentShadows.2. Inset Shadow Parsing
Added pattern matching for inset shadows in
src/native/styles/shorthands/box-shadow.ts:The
normalizeInsetValuefunction convertsinset: "inset"toinset: trueas expected by React Native'sboxShadowprop.Testing
Added 5 new tests covering:
All existing tests continue to pass.
Related